package utiles
{
	import flash.system.ApplicationDomain;

	public class Reflection
	{
		public function Reflection()
		{
		}
		
		/**
		 * 
		 * @param fullClassName
		 * @param applicationDomain
		 * @return 
		 * 
		 */		
		public static function createInstance(fullClassName:String, applicationDomain:ApplicationDomain=null):* {
			var assetCls:Class = getClass(fullClassName, applicationDomain);
			return assetCls ? new assetCls():null;
		}
		
		/**
		 * 
		 * @param fullClassName
		 * @param applicationDomain
		 * @return 
		 * 
		 */		
		public static function getClass(fullClassName:String, applicationDomain:ApplicationDomain=null):Class {
			if (applicationDomain == null) {
				applicationDomain = ApplicationDomain.currentDomain;
			}
			
//			if (applicationDomain.hasDefinition(fullClassName)) {
				return applicationDomain.getDefinition(fullClassName) as Class;
//			}
			return null;
		}
	}
}